package cn.woflcdoe.controller;

import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LuoRis
 * @date 2021/03/04 14:42
 * @description 生产者
 */
@RestController
public class HelloController {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("hello")
    public String sendMsg(String message){
        SendResult sendResult = rocketMQTemplate.syncSend("hello-springboot", message);
        System.out.println(sendResult.getMsgId());
        System.out.println(sendResult.getSendStatus());
        return "发送成功";
    }
}
